﻿using System;
using System.Collections.Generic;
using ENail.Domain.Core;
using Equation.Enterprise.Framework.Domain.Model;
using Equation.Enterprise.Framework.Web.Model;
using Equation.Enterprise.Utilities.DesignByContract;

namespace ENail.Portal.Web.Models
{
    public class EmployeeViewModel : BaseViewModel<Int16>
    {
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public DateTime BirthDay { get; set; }
        public string Address { get; set; }
        public string City { get; set; }
        public string State { get; set; }
        public string Zip { get; set; }
        public string Country { get; set; }
        public string Phone { get; set; }
        public DateTime EnrollmentDay { get; set; }
        public double CommisionPercentage { get; set; }
        public bool IsActive { get; set; }
    }

    public class EmployeeViewModelMapper : ViewModelMapper<EmployeeViewModel, Employee>
    {
        public EmployeeViewModelMapper()
        {
        }

        public override void MapDomainToView(Employee employeeDomainModel, EmployeeViewModel employeeViewModel)
        {
            Check.Require(employeeDomainModel != null);
            Check.Require(employeeViewModel != null);

            employeeViewModel.Id = employeeDomainModel.Id;
            employeeViewModel.FirstName = employeeDomainModel.FirstName;
            employeeViewModel.LastName = employeeDomainModel.LastName;
            employeeViewModel.BirthDay = employeeDomainModel.BirthDay;
            employeeViewModel.Address = employeeDomainModel.Address;
            employeeViewModel.City = employeeDomainModel.City;
            employeeViewModel.State = employeeDomainModel.State;
            employeeViewModel.Zip = employeeDomainModel.Zip;
            employeeViewModel.Country = employeeDomainModel.Country;
            employeeViewModel.Phone = employeeDomainModel.Phone;
            employeeViewModel.EnrollmentDay = employeeDomainModel.EnrollmentDay;
            employeeViewModel.CommisionPercentage = employeeDomainModel.CommisionPercentage;
            employeeViewModel.IsActive = employeeDomainModel.IsActive;
        }

        public override void MapViewToDomain(EmployeeViewModel employeeViewModel, Employee employeeDomainModel)
        {
            Check.Require(employeeDomainModel != null);
            Check.Require(employeeViewModel != null);

            employeeDomainModel.FirstName = employeeViewModel.FirstName;
            employeeDomainModel.LastName = employeeViewModel.LastName;
            employeeDomainModel.BirthDay = employeeViewModel.BirthDay;
            employeeDomainModel.Address = employeeViewModel.Address;
            employeeDomainModel.City = employeeViewModel.City;
            employeeDomainModel.State = employeeViewModel.State;
            employeeDomainModel.Zip = employeeViewModel.Zip;
            employeeDomainModel.Country = employeeViewModel.Country;
            employeeDomainModel.Phone = employeeViewModel.Phone;
            employeeDomainModel.EnrollmentDay = employeeViewModel.EnrollmentDay;
            employeeDomainModel.CommisionPercentage = employeeViewModel.CommisionPercentage;
            employeeDomainModel.IsActive = employeeViewModel.IsActive;
        }
    }
}